#define _XOPEN_SOURCE 500

#include <string.h>
#include <stdlib.h>
#include <stdio.h>

#include <stdbool.h>

#include <libusb.h>

static	const	int	VENDOR_ID		= 0x16c0;
static	const	int	PRODUCT_ID		= 0x05df;

static	const 	int	CONTROL_REQUEST_TYPE_IN = LIBUSB_ENDPOINT_IN | LIBUSB_REQUEST_TYPE_CLASS | LIBUSB_RECIPIENT_INTERFACE;
static	const	int	CONTROL_REQUEST_TYPE_OUT = LIBUSB_ENDPOINT_OUT | LIBUSB_REQUEST_TYPE_CLASS | LIBUSB_RECIPIENT_INTERFACE;

static	const	int	INTERFACE_NUMBER = 0;
static	const	int	TIMEOUT_MS = 1000;

static	const	int	HID_GET_REPORT = 0x01;
static	const	int	HID_SET_REPORT = 0x09;

static	const	int	HID_REPORT_TYPE_INPUT   = 0x01;
static	const	int	HID_REPORT_TYPE_OUTPUT  = 0x02;
static	const	int	HID_REPORT_TYPE_FEATURE = 0x03;

enum libusb_error send_feature_report(libusb_device_handle *devh, unsigned char *buffer, unsigned int length, unsigned int *transferred);

enum libusb_error receive_feature_report(libusb_device_handle *devh, unsigned char *buffer, unsigned int length, unsigned int *transferred);

enum libusb_error exchange_feature_reports_dev_id(libusb_device_handle *devh, unsigned int *id, unsigned char *family);

enum libusb_error lookup_device(libusb_context *ctx, struct libusb_device_handle **devh, unsigned int id, unsigned char family);
